Package vg.model

Source Code of vg.model.SimpleModel

package vg.model;

import java.sql.ResultSet;
import java.util.ArrayList;

import com.almworks.sqlite4java.SQLiteException;
import com.almworks.sqlite4java.SQLiteStatement;

import vg.core.AModel;
import vg.core.VisualGraph;
import vg.core.exception.CoreException;
import vg.core.exception.EnumCriticalityException;
import vg.core.graph.Graph;
import vg.core.graph.GraphNode;
import vg.core.graph.SubGraph;
import vg.core.storableGraph.StorableGraph;
import vg.core.storableGraph.StorableSubGraph;
/**
* This class is storage. In MVC architect, It is MODEL.
* @author tzolotuhin
*/
public class SimpleModel extends AModel {
  private static final int DEF_COUNT_GRAPHS = 100;
  //-------------------------------------------------------------------------
  private Graph[] graphArray;
  //-------------------------------------------------------------------------
  public SimpleModel() throws CoreException {
    this.graphArray = new Graph[DEF_COUNT_GRAPHS];
    if(this.graphArray==null)
      throw(new CoreException("[Model.Model] can not allocate memory",EnumCriticalityException.FAILED));
  }
  //-------------------------------------------------------------------------
  /**
   * This method adds a graph.
   * @throws CoreException - if no space is currently available.
   */
  public synchronized int addGraph(Graph graph) throws CoreException {
    int i, number = 0;
   
    VisualGraph.log.printDebug("[Model.addGraph] before adding a graph.");
    for(i = 0 ; i < DEF_COUNT_GRAPHS ; i++) {
      if(this.graphArray[i]==null) {
        number = i;
        this.graphArray[i] = graph;
        break;
      }
    }
    if(i==DEF_COUNT_GRAPHS) {
      throw(new CoreException("[Model.addGraph] You can not open more "+DEF_COUNT_GRAPHS+" tabs",EnumCriticalityException.WARNING));
    }
    VisualGraph.log.printDebug("[Model.addGraph] after adding a graph.");
    return(number);
  }
  /**
   * This method closes a graph.
   * @param number - number of graph, which we want to close.
   */
  public synchronized void closeGraph(int number) {
    VisualGraph.log.printDebug("[Model.closeGraph] closing of tab = "+number);
    if(number<DEF_COUNT_GRAPHS && number>=0) {
      this.graphArray[number] = null;
    }
  }
  /**
   * This method returns a graph.
   * @param number - number of graph.
   * @return graph if success and null in case of failure.
   */
  public synchronized Graph getGraph(int number) {
    if(number<DEF_COUNT_GRAPHS && number>=0)
      return(this.graphArray[number]);
    return(null);
  }
  public StorableGraph getStorableGraph(int number) {
    return null;
  }
  public StorableSubGraph getStorableSubGraph(int subGraphId) {
    return null;
  }
  public SubGraph getSubGraph(int subGraphId) {
    return null;
  }
  public StorableSubGraph getRootStorableSubGraph(int graphId) {
    return null;
  }
  public SubGraph getRootSubGraph(int graphId) {
    return null;
  }
  public String getGraphName(int graphId) {
    return null;
  }
  public SQLiteStatement executeSQLRequest(String request) throws SQLiteException {
    return null;
  }
  public void addStorableGraph(StorableGraph sg, ArrayList<Integer> subgraphIDs) {
 
  }
  public void addStorableSubGraph(StorableSubGraph ssg) {
   
  }
  public GraphNode getGraphSkeleton(int graphId) {
    return null;
  }
}
TOP

Related Classes of vg.model.SimpleModel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.